//
//  PasswordCell.m
//  KuWoCan
//
//  Created by hwd on 17/4/6.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "PasswordCell.h"

@interface PasswordCell ()

@property (nonatomic,strong) UITextField *rightTxtF;
@end

@implementation PasswordCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setUpUI];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)setUpUI
{
    _rightTxtF = [UITextField new];
    //        _rightTxtF.backgroundColor = [UIColor greenColor];
    _rightTxtF.delegate = self;
    _rightTxtF.font = KwFont(18);
    _rightTxtF.secureTextEntry = YES;
    [self.contentView addSubview:_rightTxtF];
    [_rightTxtF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(20);
        make.right.equalTo(@-20);
        make.top.equalTo(self.contentView.mas_top);
        make.height.equalTo(@(49 * screenW_6));
    }];
    
    UIView *lineView = [UIView new];
    lineView.backgroundColor = KwGaryColor;
    [self.contentView addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@0.5);
        make.left.equalTo(_rightTxtF.mas_left);
        make.right.equalTo(@-20);
        make.top.equalTo(_rightTxtF.mas_bottom);
        make.bottom.equalTo(self.contentView.mas_bottom);
    }];
}

- (void)configCell:(NSString *)title {
    _rightTxtF.placeholder = title;
}

-(BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
    if (_block)
    {
        self.block(textField.text);
    }
    
    return YES;
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [_rightTxtF resignFirstResponder];
    return YES;
}



@end
